package com.wl4837;

/**
 *  懒汉式（Lazy Initialization）
 *  双重检查锁定（Double-Checked Locking）
 */
public class DCLSingleton {
    private volatile static DCLSingleton instance;

    private DCLSingleton() {}

    public static DCLSingleton getInstance() {
        if (instance == null) {
            synchronized (DCLSingleton.class) {
                if (instance == null) {
                    instance = new DCLSingleton();
                }
            }
        }
        return instance;
    }
}
